package com.example.touch.domain;

import android.app.Activity;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Environment;
import android.util.Log;

import com.example.touch.communication.entities.PlaySound;

/**
*
* @author pla
*/
public class PlaySoundAction extends AbstractActivityAction<PlaySound>
{
	public PlaySoundAction(Activity activity, PlaySound action) 
	{
		super(activity, action);
	}
	
	@Override
	protected void executeAction() 
	{
		try
		{
			String soundID = getAction().getSoundID();			
			Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()+ "/IndoorPositioning/Sound/"+soundID);
			
			MediaPlayer mediaPlayer = MediaPlayer.create(getActivity(),  uri);
			mediaPlayer.start();
		}
		catch(Exception c)
		{
			Log.d("IO", "IO ERROR " + c.toString());
		}
	}
}
